package com.wise.mall.portal.service.ums.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.wise.mall.common.domain.response.UserDto;
import com.wise.mall.portal.dao.ums.MemberDao;
import com.wise.mall.portal.service.ums.MemberService;
import com.wise.mall.ums.entity.Member;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 会员管理Service实现类
 *
 * @author shiweinan
 */
@Service
@Slf4j
public class MemberServiceImpl implements MemberService {

    @Autowired
    private MemberDao memberDao;

    @Override
    public UserDto loadUserByUsername(String username) {
        Member member = memberDao.getByUsername(username);
        if (member != null) {
            UserDto userDto = new UserDto();
            BeanUtil.copyProperties(member, userDto);
            userDto.setPassword(null);
            userDto.setRoles(CollUtil.toList("前台会员"));
            return userDto;
        }
        return null;
    }
}
